package org.zero.common.log.event;

import lombok.RequiredArgsConstructor;
import org.springframework.context.event.EventListener;
import org.springframework.scheduling.annotation.Async;
import org.zero.common.log.feign.RemoteLogService;
import org.zero.common.api.basic.log.model.SysLogDTO;

/**
 * 异步监听日志事件
 */
@RequiredArgsConstructor
public class SysLogListener {
	private final RemoteLogService remoteLogService;

	@Async
	@EventListener(SysLogEvent.class)
	public void saveSysLog(SysLogEvent event) {
		SysLogDTO sysLog = event.getSource();
		remoteLogService.save(sysLog);
	}
}
